<script>
	import {
		load_adv_status,
		res_adv_status
	} from '@/api/api.js'
	export default {
		onLaunch: function() {
			console.log('App Launch')
			// #ifdef APP-PLUS
			plus.ad.setPrivacyConfig({
				"isAdult": true,
				"isCanUsePhoneState": true,
				"isCanUseStorage": true,
				"isCanUseLocation": true,
				"isCanUseWifiState": false,
				"isCanGetInstallAppList": false,
				"isCanGetRunningApps": false,
				"isCanGetMacAddress": true,
				"isCanGetAndroidId": true,
				"isCanGetOAID": true,
				"isCanGetIP": true,
				"isGDTAgreeStrategy": true
			})
			// this.$nextTick(() => {
			//   uni.getNetworkType({
			//     success: function (res) {
			//       if (res.networkType === "none") {
			//         uni.showModal({
			//           title: '温馨提示',
			//           content: '检测到当前网络状态不佳或无网络，请检查网络设置',
			//         })
			//       }
			//     }
			//   });
			// }) 
			let _this = this
			_this.load_adv_status()
			_this.res_adv_status()
			uni.onNetworkStatusChange(function(res) {
				console.log(res.isConnected);
				if (res.isConnected) {
					_this.load_adv_status()
					_this.res_adv_status()
				} else {
					uni.showModal({
						title: '温馨提示',
						content: '检测到当前网络状态不佳或无网络，请检查网络设置',
					})
				}
			});
			// #endif
			uni.removeStorageSync('openSHopTimes'); // 清理指定缓存 
		},
		onUnlaunch() {  
		     
		},
		onShow: function() {

		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			// 加载页广告开关
			load_adv_status() {
				load_adv_status().then((res) => {
					console.log(res, '[加载页广告开关]');
					uni.setStorageSync('load_adv_status', res.data)
				})
			},

			// 结果页广告开关
			res_adv_status() {
				res_adv_status().then((res) => {
					console.log(res, '[结果页广告开关]');
					uni.setStorageSync('res_adv_status', res.data)
				})
			},
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import "static/css/global.scss";
	@import "@/uni_modules/uview-ui/index.scss";
</style>